/**
 * 
 */
package sg.edu.nus.iss.vmcs.payment;

import java.util.HashMap;

import sg.edu.nus.iss.vmcs.system.MainController;
import sg.edu.nus.iss.vmcs.util.VMCSException;

/**
 * @author moe 
 *
 */

/**
 * ConcreteFactory Class to create the Payment object
 */
public class PaymentFactory {
	private static PaymentFactory thisObj = null;

	private PaymentFactory() {
	}

	public static PaymentFactory getInstance() {
		if (thisObj == null) {
			synchronized (PaymentFactory.class) {
				if (thisObj == null) {
					thisObj = new PaymentFactory();
				}
			}
		}
		return thisObj;
	}

	public Payment create(Payment.PaymentType paymentType, PaymentController payCtrl, MainController mainCtrl) throws VMCSException {
		Payment payment = null;
		switch (paymentType) {
		case COIN_PAYTYPE:
			payment = new CoinPayment(payCtrl, mainCtrl);
			break;
		case NETS_PAYTYPE:
			payment = new NetsPayment(payCtrl, mainCtrl);
			break;
		default:
			throw new VMCSException("PaymentFactory:create:",
					"Unkonwn Payment Type");
		}

		return payment;
	}
}
